const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
    .BundleAnalyzerPlugin;
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

const path = require('path');

const uglifyJsPlugin = new UglifyJsPlugin({
    sourceMap: true
});
const analyzer = new BundleAnalyzerPlugin();
const lodash = new LodashModuleReplacementPlugin();

module.exports = {
    entry: {
        'fetch-source': path.join(__dirname, 'source', 'index.js')
    },
    output: {
        path: path.join(__dirname, 'dist'),
        publicPath: '/dist',
        filename: '[name].js',
        library: 'fetchSource',
        libraryTarget: 'umd'
    },
    // devtool: 'eval',
    devtool: 'source-map',
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: 'babel-loader'
            }
        ]
    },
    resolve: {
        extensions: ['.js', '.json', '.less']
    },
    devServer: {
        contentBase: path.join(__dirname, "test"),
        compress: true,
        port: 9000
    },
    plugins: [lodash, uglifyJsPlugin]
};
